#ifndef __LIBIO_H
#define __LIBIO_H

#include <iostream>
#include <vector>
#include <unordered_map>
#include <string>
#include <fstream>
#include <cassert>
#include <utility> 
#include <iterator> 
#include "../includes/json.h" 
#include "../includes/libalgorithm_io.h" 

using namespace std;

typedef struct NewLine
{
    string line_name;
    string first_bus_time;
    string last_bus_time;
    vector<pair<string, int>> stations;
}StructNewLine;

typedef struct NewStation
{
    string busline;
    string last_station;
    string next_station;
    string new_station;
    int last_time;
    int next_time;
}StructNewStation;

class IO
{
public:
    // 从json文件中读取公交线路信息
    static bool readFromJsonFile2Algorithm(vector<BusLine>& busLines);

    // 输出每条线路的信息
    static void showBusLines(vector<BusLine>& busLines);

    class admin
    {
    public:
        // 录入线路信息
        static bool write2JsonbyLine(const NewLine& newLine);

        // 录入站点信息
        static bool write2JsonbyStation(const NewStation& newStation);

        // 删除线路信息
        static bool deleteFromJsonbyLine(const string& lineName);

        // 删除站点信息
        static bool deleteFromJsonbyStation(const string& lineName, const string& stationName);

    };
};


#endif // __LIBIO_H